<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setBundle basename="messages.messages"/>

<html>
<head>

<link rel="stylesheet" href="/Epics/jslib/global.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><fmt:message key="siteName"/></title>
</head>
<body>
	<%@ include file="../Template/TMainLine.jsp"%>
	<%@ include file="../Template/TMessage.jsp"%>

	<h1>${currentUser.firstName } ${currentUser.lastName }</h1>
	<br/>
	<a href="SAuthorsRSS?userId=${currentUser.id }">RSS</a>
	<br/>
	<c:if test="${!empty profileImage}">
		<img src=".${profileImage.location}"/>
	</c:if>
	
	<table>
		<tr>
			<td>Email:</td>
			<td>${currentUser.email}</td>
		</tr>
		<tr>
			<td>First name:</td>
			<td>${currentUser.firstName }</td>
		</tr>
		<tr>
			<td>Last name:</td>
			<td>${currentUser.lastName}</td>
		</tr>
		<tr>
			<td>Gender:</td>
			<td>
				<c:if test="${currentUser.gender==0}">
					Male
				</c:if>
				<c:if test="${currentUser.gender==1}">
					Female
				</c:if>
				<c:if test="${currentUser.gender==2}">
					Other
				</c:if>
			</td>
		</tr>
		<tr>
			
			<td>Date of birth:</td>
			<td><fmt:formatDate value="${currentUser.dateOfBirth }" pattern="dd/MM/yyyy" /></td>
		</tr>
		
		<c:if test="${!empty user }">
			<tr>
				<td colspan="2"><a href="SFollowers?userId=${currentUser.id}">Following/Followers</a></td>
			</tr>
		</c:if>
		
		<c:if test="${!empty user and !empty canFollow}">
		<c:choose>
			<c:when test="${canFollow}">
				<tr><td colspan="2">
					<form action="SAuthorFollow"accept-charset="UFT-8" method="post" id="inputForm">
						<input type="hidden" name="userId" value="${currentUser.id}" />
						<input type="submit" value="Follow" />
					</form>
				</td></tr>
			</c:when><c:otherwise>
				<tr><td colspan="2">
				<form action="SAuthorFollowRemove"accept-charset="UFT-8" method="post" id="inputForm">
					<input type="hidden" name="userId" value="${currentUser.id}" />
					<input type="submit" value="Remove following" />
				</form>
				</td></tr>
			</c:otherwise>
			</c:choose>
		</c:if>
		
	</table>
	
	<c:if test="${!empty user and !empty albums}">
		<h3>Albums:</h3>
		<table>
			<c:forEach items="${albums}" var="album">
				<tr>
				<c:if test="${(album.pub or currentUser.id==user.id) and !album.favorite }">
					<td><a href="SViewAlbum?albumId=${album.id}">${album.title}</a></td>
					<td>${album.description}</td>
					<c:if test="${user.id==currentUser.id}">
						<td>
							<form action="SAlbumRemove"accept-charset="UFT-8" method="post" id="inputForm">
								<input type="hidden" name="albumId" value="${album.id}" />
								<input type="submit" value="Delete album" />
							</form>
						</td>
					</c:if>
				</c:if>
				</tr>
			</c:forEach>
		</table>
	</c:if>
	
	<c:if test="${!empty topK }">
		<h3>Top photos:</h3>
		<table>
		<c:forEach items="${topK}" var="photo">
			<c:if test="${photo.pub or currentUser.id==user.id}">
				<tr>
					<td><a href="SViewPhoto?photoId=${photo.id }"><img src=".${photo.thumbnailLocation }" alt="${photo.description}"/></a></td>
					<td><a href="SViewPhoto?photoId=${photo.id }">${photo.title }</a></td>
				</tr>
			</c:if>
		</c:forEach>
		</table>
	</c:if>
	
	<c:if test="${!empty recentActivity }">
		<h3>Reacent activity:</h3>
		<table>
		<c:forEach items="${recentActivity}" var="comment">
			<tr>
				<td><b>${comment.title }</b></td>
			</tr>
			<tr>
				<td><a href="SAuthorsProfile?userId=${comment.user.id}"> ${comment.user.firstName} ${comment.user.lastName}</a></td>
			</tr>
			<tr>
				<td>${comment.contents}</td>
			</tr>
			<tr>
				<td><fmt:formatDate value="${comment.date }" pattern="dd/MM/yyyy HH:mm" /></td>
			</tr>
			<tr>
				<td><a href="SViewPhoto?photoId=${comment.photo.id }">${comment.photo.title }</a></td>
			</tr>
			
		</c:forEach>
		</table>
	</c:if>
	
	<c:if test="${!empty allPhotos }">
		<h3>All photos:</h3>
		<table>
		<c:forEach items="${allPhotos}" var="photo">
			<c:if test="${photo.pub or currentUser.id==user.id}">
				<tr>
					<td><a href="SViewPhoto?photoId=${photo.id }"><img src=".${photo.thumbnailLocation }" alt="${photo.description}"/></a></td>
					<td><a href="SViewPhoto?photoId=${photo.id }">${photo.title }</a></td>
				</tr>
			</c:if>
		</c:forEach>
		</table>
	</c:if>
	 
</body>
</html>